﻿package com.webgame.geom{
	import flash.filters.ColorMatrixFilter;
	import flash.filters.GlowFilter;
	import flash.display.Sprite;
	public class filter extends Sprite {
		// 初始化
		private var _this=this;
		private var parentObj:Object;
		private var nColor:uint;
		private var alphaVar:Number;
		private var blurXVar:Number;
		private var blurYVar:Number;
		private var strengthVar:Number;
		private var qualityVar:uint;

		private var nBrightness:int;//亮度
		private var nContrast:int;//对比度
		private var nSaturation:int;//饱和度
		private var nHue:int;//色相

		//构造函数
		public function filter() {

		}
		public function ColorMatrixHandler(displayObject:Object,nBrightness:int,nContrast:int,nSaturation:int,nHue:int) {
			_this.nBrightness=nBrightness;
			_this.nContrast=nContrast;
			_this.nSaturation=nSaturation;
			_this.nHue=nHue;
			filterHandler(displayObject);
		}
		public function GlowHandler(displayObject:Object,nColor:uint,alphaVar:Number,blurXVar:Number,blurYVar:Number,strengthVar:Number,qualityVar:int) {
			_this.nColor=nColor;
			_this.alphaVar=alphaVar;
			_this.blurXVar=blurXVar;
			_this.blurYVar=blurYVar;
			_this.strengthVar=strengthVar;
			_this.qualityVar=qualityVar;
			filterHandler(displayObject);
		}
		private function filterHandler(displayObject:Object) {
			var cm:ColorMatrix=new ColorMatrix();
			cm.adjustColor(nBrightness,nContrast, nSaturation, nHue);
			var filter1:ColorMatrixFilter=new ColorMatrixFilter(cm);
			var filter2:GlowFilter=new GlowFilter(nColor,alphaVar,blurXVar,blurYVar,strengthVar,qualityVar);
			var filters:Array = new Array();
			filters.push(filter1);
			filters.push(filter2);
			displayObject.filters=filters;
		}
	}
}

//import flash.filters.GlowFilter;
//var glow:GlowFilter=new GlowFilter(0x11EED8,Var,Blue,Blue,2,3);
//tmpObj.filters=[glow];